package top.hcode.hoj.controller.admin;

import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import top.hcode.hoj.common.result.CommonResult;
import top.hcode.hoj.pojo.dto.BaseIdDTO;
import top.hcode.hoj.pojo.dto.QuerySampleDTO;
import top.hcode.hoj.pojo.entity.coll.CollCreatedWorksScore;
import top.hcode.hoj.service.admin.AdminCollCreatedWorksScoreService;

/**
 * @author orangej
 * @since 2025-01-26
 */
@Slf4j
@RestController
@RequestMapping("/api")
@RequiredArgsConstructor
public class AdminCollCreatedWorksScoreController {

    private final AdminCollCreatedWorksScoreService collCreatedWorksScoreService;

    @GetMapping("/admin/coll-created-works-score/list")
    public CommonResult<IPage<CollCreatedWorksScore>> getCollCreatedWorksScoreList(QuerySampleDTO querySampleDTO) {
        return CommonResult.successResponse(collCreatedWorksScoreService.getCollCreatedWorksScoreList(querySampleDTO));
    }

    @PostMapping("/admin/coll-created-works-score/save")
    public CommonResult<CollCreatedWorksScore> saveCollCreatedWorksScore(@RequestBody CollCreatedWorksScore collCreatedWorksScore) {
        return CommonResult.successResponse(collCreatedWorksScoreService.saveCollCreatedWorksScore(collCreatedWorksScore));
    }

    @PostMapping("/admin/coll-created-works-score/delete")
    public CommonResult<Void> deleteCollCreatedWorksScore(@RequestBody BaseIdDTO dto) {
        collCreatedWorksScoreService.deleteCollCreatedWorksScore(dto.getId());
        return CommonResult.successResponse();
    }

}
